/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 */
package com.jeesite.modules.st.entity.formula;

import com.jeesite.common.mybatis.annotation.JoinTable;
import com.jeesite.modules.st.entity.StMaterialRecord;
import com.jeesite.modules.st.entity.StSmallMaterialApprove;
import org.hibernate.validator.constraints.Length;

import com.jeesite.common.entity.DataEntity;
import com.jeesite.common.mybatis.annotation.Column;
import com.jeesite.common.mybatis.annotation.Table;
import com.jeesite.common.mybatis.mapper.query.QueryType;

import java.math.BigDecimal;

/**
 * 生产配方Entity
 *
 * @author HOHD
 * @version 2020-12-31
 */
@Table(name = "st_formula_detail", alias = "a", columns = {
        @Column(name = "id", attrName = "id", label = "id", isPK = true),
        @Column(name = "material_name", attrName = "materialName", label = "原料名称", queryType = QueryType.LIKE),
        @Column(name = "percent_in", attrName = "percentIn", label = "占比%"),
        @Column(name = "per_weigh", attrName = "perWeigh", label = "每吨重量"),
        @Column(name = "formula_name_id", attrName = "formulaNameId.id", label = "配方id", queryType = QueryType.LIKE),
}, orderBy = "a.id ASC", joinTable = {
        @JoinTable(on = "a.material_name = m.id", type = JoinTable.Type.LEFT_JOIN, attrName = "materialRecord", entity = StMaterialRecord.class, alias = "m"),
        @JoinTable(on = "m.material_code=approve.material_code", type = JoinTable.Type.LEFT_JOIN, alias = "approve", attrName = "materialRecord.smallMaterialApprove", entity = StSmallMaterialApprove.class)
}
)
public class StFormulaDetail extends DataEntity<StFormulaDetail> {

    private static final long serialVersionUID = 1L;
    private String materialName;        // 原料名称
    private StMaterialRecord materialRecord;
    private BigDecimal percentIn;        // 占比%
    private BigDecimal perWeigh;        // 每吨重量
    private StFormulaNameChild formulaNameId;        // 配方id 父类

    public StFormulaDetail() {
        this(null);
    }


    public StFormulaDetail(StFormulaNameChild formulaNameId) {
        this.formulaNameId = formulaNameId;
    }

    public StMaterialRecord getMaterialRecord() {
        return materialRecord;
    }

    public void setMaterialRecord(StMaterialRecord materialRecord) {
        this.materialRecord = materialRecord;
    }

    @Length(min = 0, max = 20, message = "原料名称长度不能超过 20 个字符")
    public String getMaterialName() {
        return materialName;
    }

    public void setMaterialName(String materialName) {
        this.materialName = materialName;
    }

    public BigDecimal getPercentIn() {
        return percentIn;
    }

    public void setPercentIn(BigDecimal percentIn) {
        this.percentIn = percentIn;
    }

    public BigDecimal getPerWeigh() {
        return perWeigh;
    }

    public void setPerWeigh(BigDecimal perWeigh) {
        this.perWeigh = perWeigh;
    }

    @Length(min = 0, max = 36, message = "配方id长度不能超过 36 个字符")
    public StFormulaNameChild getFormulaNameId() {
        return formulaNameId;
    }

    public void setFormulaNameId(StFormulaNameChild formulaNameId) {
        this.formulaNameId = formulaNameId;
    }

}